#include <assert>

namespace DLIB2
{
	#define DLIB_READ_ONLY 111
	#define DLIB_WRITE_ONLY 222
	#define DLIB_READ_WRITE 333
	 
	template <typename Container, typename ValueType, int nPropType>
	class DLIB_Property
	{
	public:
	DLIB_Property()
	{
		m_cObject = NULL;
		Set = NULL;
		Get = NULL;
	}

	void setContainer(Container* cObject)
	{
		m_cObject = cObject;
	}

	void setter(void (Container::*pSet)(ValueType value))
	{
		if((nPropType == DLIB_WRITE_ONLY) || (nPropType == DLIB_READ_WRITE))
			Set = pSet;
		else
			Set = NULL;
	}

	void getter(ValueType (Container::*pGet)())
	{
		if((nPropType == DLIB_READ_ONLY) || (nPropType == DLIB_READ_WRITE))
			Get = pGet;
		else
			Get = NULL;
	}

	ValueType operator =(const ValueType& value)
	{
		assert(m_cObject != NULL);
		assert(Set != NULL);
		(m_cObject->*Set)(value);
		return value;
	}

	operator ValueType()
	{
		assert(m_cObject != NULL);
		assert(Get != NULL);
		return (m_cObject->*Get)();
	}
	private:
		Container* m_cObject;

		void (Container::*Set)(ValueType value);

		ValueType (Container::*Get)();
	};
}